<template>
	<view class="home">
		<view class="bg-1a padding-left-30 padding-tb-40 padding-right-60 flex align-center radius-40 margin-bottom-40">
			<image :src="data.avatar" mode="" class="headimg"></image>
			<view class="flex-one text-32 text-bold text-ff flex-one margin-lr-30">{{data.nickname}}</view>
			<view class="coupbtn" @click="go('/pages/my/mycoupon')">我的券包</view>
		</view>
		<view class="bg-ff bg-shadow radius-40 flex align-center margin-bottom-40" v-for="(item,index) in list"
			:key="index">
			<view class="coupbg flex align-center flex-direction">
				<view class="text-ff margin-top-10" style="font-size: 72rpx;"> <text class="text-32">￥</text> {{item.money}}</view>
				<view class="text-24 text-ff">{{item.name}}</view>
			</view>
			<view class="flex-one margin-lr-20">
				<view class="text-32">满{{item.min_money}}元可用</view>
				<view class="text-24 text-99 margin-top-10">{{item.expire_time_text}}</view>
			</view>
			<view class="lqbtn" @click="getCoupon(item.id)">马上领取</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: {},
				list:[]
			}
		},
		onReady() {
			this.rq.getData('Wechat/user_info', {}).then(res => {
				if (res.code == 1) {
					this.data = res.data
				}
			})
			this.loadList(1)
		},
		methods: {
			loadList(first_page) {
				this.rq.getList('coupon/coupon_list', {}, {
					that: this,
					first_page
				})
			},
			getCoupon(id){
				this.rq.getData('coupon/takeCoupon',{
					coupon_id:id
				}).then(res=>{
					if(res.code==1){
						this.cn.alert('领取成功')
						this.loadList(1)
					}
				})
			}
		},
		onReachBottom() {
			this.loadList(0)
		}
	}
</script>

<style>
	.home {
		width: 100%;
		min-height: 100vh;
		background: #fff;
		padding: 40rpx 30rpx;
	}

	.headimg {
		width: 106rpx;
		height: 106rpx;
		border-radius: 50%;
	}

	.coupbtn {
		width: 232rpx;
		height: 72rpx;
		background: #FFFFFF;
		border-radius: 200rpx 200rpx 200rpx 200rpx;
		font-weight: bold;
		font-size: 28rpx;
		color: #101010;
		line-height: 72rpx;
		text-align: center;
	}

	.coupbg {
		width: 176rpx;
		height: 164rpx;
		background: #101010;
		border-radius: 40rpx 40rpx 40rpx 40rpx;
	}

	.lqbtn {
		width: 184rpx;
		height: 68rpx;
		background: #101010;
		border-radius: 200rpx 200rpx 200rpx 200rpx;
		font-size: 24rpx;
		color: #FFFFFF;
		line-height: 68rpx;
		text-align: center;
		margin-right: 20rpx;
	}
</style>